﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using UserControl;
using Module;


public partial class CouponCount : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            countCouponNo10();
            countCouponNo30();
            countCouponNo50();
        }
    }

    /// <summary>
    /// 10块统计
    /// </summary>
    private void countCouponNo10(){
           string sql = string.Empty;
            sql = @"DECLARE 
                    @lbl_couponno10_1 int,
                    @lbl_couponno10_2 int,
                    @lbl_couponno10_3 int
                    set @lbl_couponno10_1=(select count(*) from Coupon)
                    set @lbl_couponno10_2=(select count(*) from Coupon where status=1)
                    set @lbl_couponno10_3=@lbl_couponno10_1-@lbl_couponno10_2
                    select 
                    @lbl_couponno10_1 as lbl_couponno10_1,@lbl_couponno10_2 as lbl_couponno10_2,@lbl_couponno10_3 as lbl_couponno10_3
                    ";
                     
                DataTable coupDatas = Util.loadSql(sql);
                if (coupDatas.Rows.Count > 0)
                {
                    this.lbl_couponno10_1.Text = Util.objectToString(coupDatas.Rows[0]["lbl_couponno10_1"]);
                    this.lbl_couponno10_2.Text = Util.objectToString(coupDatas.Rows[0]["lbl_couponno10_2"]);
                    this.lbl_couponno10_3.Text = Util.objectToString(coupDatas.Rows[0]["lbl_couponno10_3"]);
                }

    }

    /// <summary>
    /// 30块统计
    /// </summary>
    private void countCouponNo30()
    {
        string sql = string.Empty;
        sql = @"DECLARE 
                    @lbl_couponno30_1 int,
                    @lbl_couponno30_2 int,
                    @lbl_couponno30_3 int
                    set @lbl_couponno30_1=(select count(*) from Coupon2)
                    set @lbl_couponno30_2=(select count(*) from Coupon2 where status=1)
                    set @lbl_couponno30_3=@lbl_couponno30_1-@lbl_couponno30_2
                    select 
                    @lbl_couponno30_1 as lbl_couponno30_1,@lbl_couponno30_2 as lbl_couponno30_2,@lbl_couponno30_3 as lbl_couponno30_3
                    ";

        DataTable coupDatas = Util.loadSql(sql);
        if (coupDatas.Rows.Count > 0)
        {
            this.lbl_couponno30_1.Text = Util.objectToString(coupDatas.Rows[0]["lbl_couponno30_1"]);
            this.lbl_couponno30_2.Text = Util.objectToString(coupDatas.Rows[0]["lbl_couponno30_2"]);
            this.lbl_couponno30_3.Text = Util.objectToString(coupDatas.Rows[0]["lbl_couponno30_3"]);
        }

    }


    /// <summary>
    /// 50块统计
    /// </summary>
    private void countCouponNo50()
    {
        string sql = string.Empty;
        sql = @"DECLARE 
                    @lbl_couponno50_1 int,
                    @lbl_couponno50_2 int,
                    @lbl_couponno50_3 int
                    set @lbl_couponno50_1=(select count(*) from Coupon3)
                    set @lbl_couponno50_2=(select count(*) from Coupon3 where status=1)
                    set @lbl_couponno50_3=@lbl_couponno50_1-@lbl_couponno50_2
                    select 
                    @lbl_couponno50_1 as lbl_couponno50_1,@lbl_couponno50_2 as lbl_couponno50_2,@lbl_couponno50_3 as lbl_couponno50_3
                    ";

        DataTable coupDatas = Util.loadSql(sql);
        if (coupDatas.Rows.Count > 0)
        {
            this.lbl_couponno50_1.Text = Util.objectToString(coupDatas.Rows[0]["lbl_couponno50_1"]);
            this.lbl_couponno50_2.Text = Util.objectToString(coupDatas.Rows[0]["lbl_couponno50_2"]);
            this.lbl_couponno50_3.Text = Util.objectToString(coupDatas.Rows[0]["lbl_couponno50_3"]);
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        countCouponNo10();
        countCouponNo30();
        countCouponNo50();
    }
}
